/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/5/8
 * \* Time: 15:23
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 圆圈中最后剩下的数字_约瑟夫环 {
    public int lastRemaining(int n, int m) {
        int ans=0;
        //开始反推，最后一轮剩下2个人，从2开始反推
        for(int i=2;i<=n;i++){
            ans=(ans+m)%i;
        }
        return ans;
    }
}